#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>
#include <math.h>
#include <string.h>

void main()
{
	FILE *given_file;
	int probel = 0;	
	int i;
	char ch;
	int simbol = 0, word = 0, line = 0;
	



	given_file = fopen ("test.txt", "rb");

	if (given_file == NULL)
		printf("fail %s\n","text.txt");
	else 
	{
		
	while((ch=fgetc(given_file)) != EOF){
			
		simbol ++;

		if(simbol == 1)
			{
				line++;
				if (!isspace(ch))
					word++;
			}
										
			simbol ++;
			

			if ( isspace(ch) == 0)
				probel = 1;

			if (ch == '\n' || ch == EOF  )
				line++;
			
			if ( !isspace(ch)  && probel == 1 ){
				probel = 0;
				word++;
			}


		}
	}
	printf("\nlines: %d\nwords: %d\nsimbol: %d\n", line, word, simbol);

	fclose(given_file);
	system("PAUSE");
	
}